// pages/good/good.js
Page({
  data: {
      topTab:[
        {
        sex:'男生',
        ctype:1,
        seed:6515
      },{
        sex:'女生',
        ctype:2,
        seed:5425
      }],
      sourceId:'',
      sourceName:'',
      plateList:[
        { 
          title:'分类',
          logeUrl:'https://cdn.motieimg.com/store/df8957907895e5afd47eb6c64e464bfc.png'
        },{
          title:'排行',
          logeUrl:'https://cdn.motieimg.com/store/e7e3ceaeac429214e7547f34b5bc17c4.png'
        }
        ,{
          title:'专题',
          logeUrl:'https://cdn.motieimg.com/store/2a8d03f1b8ee3e6168582b10c8c5bb84.png'
        }
        ,{
          title:'免费',
          logeUrl:'https://cdn.motieimg.com/store/aa87fbe0e4f9170feb7bb4be3a5b4e0e.png'
        }
      ],
      select:false,
      selected:'true'
      // num:0,
     
  },
  // 男生，女生分类展示
  select: function( e ) {
    var that = this;
    let ctype=that.data.topTab[e.currentTarget.id].ctype
    let seed=that.data.topTab[e.currentTarget.id].seed
    console.log(e)
    if(e.currentTarget.id  == '0' ) {
      that.setData( {
        selected:true,
        select:false
    })
    wx.request({
      url: 'https://m.taoyuewenhua.com/ajax/book_mall', 
      methods:'GET',
      data:{
        ctype,
        seed
      },
      header:{
        'Content-Type':'application/json '
      },success:function(res){
        console.log(res.data,'select id==0')
        that.setData({
          resdata:res.data,
        })
      },
      fail:function(res){
        console.log('fail');
      }
    })
    } else if( e.currentTarget.id=='1' ) {
      console.log(e.currentTarget.id)
        that.setData( {
          selected:false,
          select:true
        })
        wx.request({
          url: 'https://m.taoyuewenhua.com/ajax/book_mall', 
          data:{
            ctype,
            seed
          },
          methods:'GET',
          header:{
          },success:function(res){
            console.log(res.data,'select id==1')
            that.setData({
              resdata:res.data,
            })
          },
          fail:function(res){
            console.log('fail');
          }
        })
    }
  },

   jumpBtn0:function(options){
    wx.navigateTo({
      url: '../classify/classify',
    })
   },
   jumpBtn1:function(options){
    wx.navigateTo({
      url: '../classify/classify',
    })
   },
   jumpBtn2:function(options){
    wx.navigateTo({
      url: '../classify/classify',
    })
   },
   jumpBtn3:function(options){

    wx.navigateTo({
      url: '../classify/classify',
    })
   },
   goList:function(options){
     wx.navigateTo({
       url: '../classify/classify',
     })
   },
  getData(e){
    var that=this
    console.log(e,333)
    // that.data.sourceId=
    // that.data.sourceName=
    console.log(that.data.resdata.data.channelList[0].bookList,6666)
    console.log(e.currentTarget.dataset.name,777)
    wx.navigateTo({
      url: `../recommend/recommend?data=`+JSON.stringify(e.currentTarget.dataset.name),
    })
  },
  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
  var that=this;
  console.log(that)
  wx.request({
    url: 'https://m.taoyuewenhua.com/ajax/book_mall', 
    methods:'GET',
    data:{
      ctype:1,
      seed:6515
    },
    header:{
      // 'Content-Type':'application/json '
    },success:function(res){
      console.log(res.data,222)
      that.setData({
        resdata:res.data,
      })
    },
    fail:function(res){
      console.log('fail');
    }
  })
  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {

  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {
    // return {
    //   title: 'swiper',
    //   path: 'page/component/pages/swiper/swiper'
    // }
  }
})